package com.zzld.core.service;

import java.util.List;

import com.github.pagehelper.PageInfo;

/**
 * 基础的service接口,所有的service都必须实现此接口
 * 
 * @author zzld
 * 
 * @param <T>
 */
public interface IBaseService<T> {

	/**
	 * 
	 * @Title: save
	 * @Description: TODO 插入全部数据
	 * @param:@param entity
	 * @param:@return
	 * @param:@throws Exception
	 * @return: int
	 * @throws 
	 */
	public int save(T entity) throws Exception;

	/**
	 * 
	 * @Title: saveSelective
	 * @Description: TODO 只插入不为null的数据,不影响有默认值的字段
	 * @param:@param entity
	 * @param:@return
	 * @param:@throws Exception
	 * @return: int
	 * @throws 
	 */
	public int saveSelective(T entity) throws Exception;

	/**
	 * 
	 * @Title: updateByPrimaryKey
	 * @Description: TODO 根据主键进行更新,这里最多只会更新一条数据
	 * @param:@param entity
	 * @param:@return
	 * @return: int
	 * @throws 
	 */
	public int updateByPrimaryKey(T entity) throws Exception;

	/**
	 * 
	 * @Title: updateByPrimaryKeySelective
	 * @Description: TODO 根据主键进行更新,只会更新不是null的数据
	 * @param:@param entity
	 * @param:@return
	 * @return: int
	 * @throws 
	 */
	public int updateByPrimaryKeySelective(T entity) throws Exception;

	/**
	 * 根据实体类不为null的字段进行查询,条件全部使用=号and条件
	 * 
	 * @param <T extend T>
	 */
	public int delete(T key) throws Exception;

	/**
	 * 
	 * @Title: deleteByPrimaryKey
	 * @Description: TODO 根据主键删除数据
	 * @param:@param key
	 * @param:@return
	 * @param:@throws Exception
	 * @return: int
	 * @throws 
	 */
	public int deleteByPrimaryKey(Object key) throws Exception;

	/**
	 * 
	 * @Title: select
	 * @Description: TODO 根据实体类不为null的字段进行查询
	 * @param:@param entity
	 * @param:@return
	 * @param:@throws Exception
	 * @return: List<T>
	 * @throws 
	 */
	public List<T> select(T entity) throws Exception;

	/**
	 * 
	 * @Title: selectCount
	 * @Description: TODO 根据实体类不为null的字段进行查询总数
	 * @param:@param entity
	 * @param:@return
	 * @param:@throws Exception
	 * @return: int
	 * @throws 
	 */
	public int selectCount(T entity) throws Exception;

	/**
	 * 
	 * @Title: selectByPrimaryKey
	 * @Description: TODO 根据主键进行查询,必须保证结果唯一 单个字段做主键时,可以直接写主键的值
	 *               联合主键时,key可以是实体类,也可以是Map
	 * @param:@param key
	 * @param:@return
	 * @param:@throws Exception
	 * @return: T
	 * @throws 
	 */
	public T selectByPrimaryKey(Object key) throws Exception;
	
	
	public  List<T>  selectByExample(Object example) throws Exception;
	
	public int selectCountByExample(Object example) throws Exception;

	/**
	 * 
	 * @Title: selectPage
	 * @Description: TODO 单表分页
	 * @param:@param pageNum
	 * @param:@param pageSize
	 * @param:@param record
	 * @param:@return
	 * @param:@throws Exception
	 * @return: PageInfo<T>
	 * @throws 
	 */
	public PageInfo<T> selectPage(int pageNum, int pageSize, T record) throws Exception;

	
	/**
	 * 
	 * @Title: selectPageByExample example分页,排序
	 * @Description: TODO
	 * @param:@param pageNum
	 * @param:@param pageSize
	 * @param:@param example
	 * @param:@return
	 * @param:@throws Exception
	 * @return: PageInfo<T>
	 * @throws 
	 */
	public PageInfo<T> selectPageByExample(int pageNum, int pageSize,Object example) throws Exception;
}
